"""
@Author:WKVugen
@Time:2023-06-29
@Description: 修改
"""
import time

from selenium.webdriver.common.by import By

from base.base_page import BasePage
from pageobject.login_page import LoginPage
from utils.tianDog import LuckyDog


class EditDemandPage(BasePage):
    # 页面元素
    supplier_demand_loc = (By.XPATH, "//span[text()='供应商招募管理']")
    demand_manage_loc = (By.XPATH, "//span[text()='招募需求管理']")
    edit_button_01_loc = (By.XPATH, "//*[@id='app']/div/div[2]/section/div/div[3]/div/div[1]/div[4]/div[2]/table/tbody/tr[1]/td[10]/div/button[2]")
    demand_comment_loc =(By.XPATH, "//textarea[@placeholder='请输入需求描述']")
    banner_move_loc = (By.XPATH, "//span[@title='移除']")
    banner_input_loc = (By.XPATH, "//input[@type='file']")
    save_loc = (By.XPATH, "//span[text()='保存']")
    # 页面行为
    def eidt_demand(self):
        # 登陆
        lg = LoginPage(self.driver)
        lg.login_demand()
        # 进入管理页面
        self.click(EditDemandPage.supplier_demand_loc)
        time.sleep(1)
        self.click(EditDemandPage.demand_manage_loc)
        time.sleep(3)
        self.click(EditDemandPage.edit_button_01_loc)
        ld = LuckyDog()
        data = ld.tian_dog_diary()
        demand_comment = data["result"]["content"]
        time.sleep(2)
        self.clear(EditDemandPage.demand_comment_loc)
        self.set_keys(EditDemandPage.demand_comment_loc, demand_comment)
        # 上传banner
        time.sleep(1)
        self.click(EditDemandPage.banner_move_loc)
        time.sleep(1)
        self.set_keys(EditDemandPage.banner_input_loc, "D:/upload/banner.png")
        time.sleep(2)
        self.click(EditDemandPage.save_loc)
